package com.hqq.exercise.bit;

/**
 * AddTwoNumWithoutOperator
 * 不用运算符求两个数的和
 * Created by heqianqian on 2017/8/15.
 */
public class AddTwoNumWithoutOperator {
    public static int add(int num1, int num2) {
        while (num2 != 0) {
            int temp = num1^num2;
            num2 = (num1&num2)<<1;
            num1 = temp;
        }
        return num1;
    }
}
